import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

export default new Router({
    routes: [
        { path: '/login', component: resolve => require.ensure([], () => resolve(require('@/views/login/login')), 'login')},
        {
            path: '/',
            component: resolve => require.ensure([], () => resolve(require('@/views/common/Home')), 'api'),
            children: [
                {path: '/api', name: '首页', component: resolve => require.ensure([], () => resolve(require('@/views/index')), 'api')},
                {
                    path: '/interface', 
                    name: '接口', 
                    component: resolve => require.ensure([], () => resolve(require('@/views/interface/index')), 'interfaceindex'),
                    children:[
                        {
                            path: 'project',
                            component: resolve => require.ensure([], () => resolve(require('@/views/interface/project')), 'project'),
                            meta: { title: '项目管理' },
                        },   
                        {
                            path: 'module',
                            component: resolve => require.ensure([], () => resolve(require('@/views/interface/module')), 'module'),
                            meta: { title: '模块管理' },
                        }, 
                        {
                            path: 'interface',
                            component: resolve => require.ensure([], () => resolve(require('@/views/interface/interface')), 'interface'),
                            meta: { title: 'Api管理' },
                        }, 
                    ]
                },
                {
                    path: '/system', 
                    name: '系统配置', 
                    component: resolve => require.ensure([], () => resolve(require('@/views/system/index')), 'systemindex'),
                    children:[
                        {
                            path: 'menu',
                            component: resolve => require.ensure([], () => resolve(require('@/views/system/menu')), 'menu'),
                            meta: { title: '菜单管理' }
                        },
                        {
                            path: 'role',
                            component: resolve => require.ensure([], () => resolve(require('@/views/system/role')), 'role'),
                            meta: { title: '角色管理' }
                        },
                        {
                            path: 'systemuser',
                            component: resolve => require.ensure([], () => resolve(require('@/views/system/user')), 'user'),
                            meta: { title: '员工管理' }
                        },
                        {
                            path: 'message',
                            component: resolve => require.ensure([], () => resolve(require('@/views/system/message')), 'message'),
                            meta: { title: '消息管理' }
                        }, 
                    ]
                },
            ]
        },
        { path: '/404', component: resolve => require.ensure([], () => resolve(require('@/views/common/404')), 'message')},
        { path: '/403', component: resolve => require.ensure([], () => resolve(require('@/views/common/403')), 'message')},
        {
            path: '*',
            redirect: '/404'
        }
    ]
})
